<!DOCTYPE html>
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
 <style type="text/css">
  body, html{width: 100%;height: 100%;margin:0;font-family:"";}
  #allmap{height:500px;width:100%;}
  #r-result{width:100%;}
 </style>
 <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
 <title>添加动画标注点</title>
</head>
<body>
 <div id="allmap"></div>
 <div id="control">
  <button onclick = "show1();">输出坐标</button>
 </div>
</body>
</html>

<script type="text/javascript">
 // API
 var map = new BMap.Map("allmap");
 map.centerAndZoom(new BMap.Point(121.383854,31.163382), 15);
 map.enableScrollWheelZoom();

  
 
var polygonList=[];
var polygonPathList=[];
setTimeout(function(){
    map.clearOverlays();        //
  polygonPathList=getBoundary(points.pq1,"blue");
 map.setViewport(polygonPathList);
}, 1000);
  
  function show1(){
   
    for(var j=0;j<polygonList.length;j++){
  // console.log(polygonList[j])
      var point1=polygonList[j].Ko;

      
      var p='';
      for(let i in point1){
          p+='['+point1[i].lng+','+point1[i].lat+'],';
      }
      //输出坐标
      console.log(p);
    }
  //console.log(polygonList[1].ia);
  }
  function getBoundary(point,color){
    if(!color)
      color="red"
    var PolygonPointLf = [];
    for (var i = 0;i<point.length;i++){
        PolygonPointLf.push(new BMap.Point(point[i][0],point[i][1]));
    }
    var polygon = new BMap.Polygon(PolygonPointLf, {strokeColor:color, strokeWeight:2, fillOpacity:0.2,fillColor:color});  //
polygon.enableEditing();
    polygonList.push(polygon);
    map.addOverlay(polygon);           //
    return polygon.getPath();
}
  var points = {};
points.pq1 = [[121.534513,31.11078],[121.534944,31.10911],[121.538088,31.110502],[121.537352,31.112001]];
  points.pq2 = [[121.538448,31.11248],[121.539166,31.111336],[121.540352,31.111847],[121.539633,31.113021]];



</script>